home *** CD-ROM | disk | FTP | other *** search
/ Freelog 22 / freelog 22.iso / Prog / Djgpp / GPC2952B.ZIP / doc / gpc / docdemos / exitdemo.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2001-02-09  |  521 b   |  25 lines

  1. program ExitDemo;
  2.  
  3. procedure Foo (Bar: Integer);
  4. var
  5.   Baz, Fac: Integer;
  6. begin
  7.   if Bar < 1 then
  8.     Exit;                  { Exit foo }
  9.   Fac := 1;
  10.   for Baz := 1 to Bar do
  11.     begin
  12.       Fac := Fac * Baz;
  13.       if Fac >= Bar then       { Exit foo }
  14.         Exit;
  15.       WriteLn (Bar,' is greater then ', baz, '!, which is equal to ', Fac)
  16.   end
  17. end;
  18.  
  19. begin
  20.   Foo (-1);
  21.   Foo (789);
  22.   Exit;                  { Terminates program }
  23.   Foo (987654321)        { This is not executed any more }
  24. end.
  25.